export function sortByField<T extends Object, K extends keyof T>(arr: T[], field: K, asc = true) {
  return asc
    ? arr.sort((a, b) => {
        if (a[field] > b[field]) {
          return 1
        }
        if (a[field] == b[field]) {
          return 0
        }
        return -1
      })
    : arr.sort((a, b) => {
        if (a[field] < b[field]) {
          return 1
        }
        if (a[field] == b[field]) {
          return 0
        }
        return -1
      })
}
